# Group Roles

**ADMIN**

To create or modify data of this data layer, you will need admin access. You can get the data without admin access as well.

| Parameter | Description | Type | Required |
|:----------|-------------|------|----------|
| `name`  | Name of the role | integer | **yes** |
| `title-name` | Title of the role | integer | - |

## Roles Collection [/v1/roles{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `name`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### List Roles [GET]
Get a list of Roles.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "meta": {
                "count": 1
            },
            "data": [
                {
                    "attributes": {
                        "name": "example-coorganizer",
                        "title-name": "Co-organizer"
                    },
                    "type": "role",
                    "id": "1",
                    "links": {
                        "self": "/v1/roles/1"
                    }
                }
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/roles"
            }
        }


### Create Role [POST]
Create a new general role by admins.

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
              "data": {
                "attributes": {
                  "name": "example-coorganizer",
                  "title-name": "Co-organizer"
                },
                "type": "role"
              }
            }

+ Response 201 (application/vnd.api+json)

        {
            "data": {
                "attributes": {
                    "name": "example-coorganizer",
                    "title-name": "Co-organizer"
                },
                "type": "role",
                "id": "1",
                "links": {
                    "self": "/v1/roles/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/roles/1"
            }
        }

## Role Details [/v1/roles/{role_id}]
+ Parameters
    + role_id: 1 (integer) - ID of the role in the form of an integer

### Get Role Details [GET]
Get a single role.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
          "data": {
            "attributes": {
              "name": "example-coorganizer",
              "title-name": "Co-organizer"
            },
            "type": "role",
            "id": "1",
            "links": {
              "self": "/v1/roles/1"
            }
          },
          "jsonapi": {
            "version": "1.0"
          },
          "links": {
            "self": "/v1/roles/1"
          }
        }


### Update Role [PATCH]
Update a single role by `id` (only admin).

+ `id` (integer) - ID of the record to update **(required)**

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
              "data": {
                "attributes": {
                  "name": "example-coorganizer",
                  "title-name": "Co-organizer"
                },
                "id": "1",
                "type": "role"
              }
            }

+ Response 200 (application/vnd.api+json)

            {
                "data": {
                    "attributes": {
                        "name": "example-coorganizer",
                        "title-name": "Co-organizer"
                    },
                    "type": "role",
                    "id": "1",
                    "links": {
                        "self": "/v1/roles/1"
                    }
                },
                "jsonapi": {
                    "version": "1.0"
                },
                "links": {
                    "self": "/v1/roles/1"
                }
            }

### Delete Role [DELETE]
Delete a single Role.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
          "meta": {
            "message": "Object successfully deleted"
          },
          "jsonapi": {
            "version": "1.0"
          }
        }


## Get Role for a Role Invite [/v1/role-invites/{role_invite_id}/role]
+ Parameters
    + role_invite_id: 1 (integer) - ID of the role invite in the form of an integer

### Get Role Details for a Role Invite [GET]
Get a single role.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "attributes": {
                    "title-name": "Organizer",
                    "name": "organizer"
                },
                "type": "role",
                "id": "1",
                "links": {
                    "self": "/v1/roles/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/roles/1"
            }
        }
